Meredith O'Malley's profile

RenderMan ST Coloration

R E N D E R M A N  S T  C O L O R A T I O N
____________________________________________________________________________________________________
 
These images show the results of using the RenderMan's Open Shading Language (OSL) to write a variety of traditional surface shaders. The notes and OSL code accompanying each image depict how each pattern was created.
S Q U A R E
____________________________________________________________________________________________________
 

// square.osl
shader square(color fgcolor = color(1,0,0), color bgcolor = color(0,0,1),
                                                                       float u_min = 0.2,
                                                                       float u_max = 0.8,
                                                                       float v_min = 0.2,
                                                                       float v_max = 0.8,
                                                                       output color resultRGB = 0)
{
if(u > u_min && u < u_max && v > v_min && v < v_max)
resultRGB = fgcolor;
else
                 resultRGB = 1;
}
 
C I R C L E 
____________________________________________________________________________________________________
 

// circle.osl
shader circle(color fgcolor = color(0.5,1,0.2),
                                           float radius = 0.5,
                                        output color resultRGB = 0)
{
if(sqrt((u - 0.1) * (u - 0.2) + (v - 0.2) * (v - 0.2)) >= radius)
        resultRGB = fgcolor;
else
        resultRGB = 1;
}
 
S E M I C I R C L E
____________________________________________________________________________________________________
 
 
// semicircle.osl
shader semicircle(color fgcolor = color(0.5,0,0.2),
                                                  float radius = 0.5,
                                          output color resultRGB = 0)
{
if(sqrt((u - 0.5) * (u - 0.5) + (v - 0) * (v - 0)) >= radius)
            resultRGB = fgcolor;
else
            resultRGB = 1;
}
P A R A B O L A
____________________________________________________________________________________________________
 

//parabola.osl
shader parabola(color fgcolor = color(0,0,1), color bgcolor = color(1,0,0),
                                                                                     float u_wipe = 0.5,
                                                                                     float v_wipe = 0.1,
                                                                                        float width = 10,
                                                                        output color resultRGB = 0,
                                                                               output float resultF = 0 )
{
float usquare = (u-u_wipe)*(u-u_wipe);
 
if(v > width*usquare + v_wipe)
              resultRGB = fgcolor;
else
              resultRGB = bgcolor;
}
 
 
S I N  W A V E
____________________________________________________________________________________________________
 

//sinwave.osl
shader sinwave(float t_cutoff = 0.5,
   
                        float midpoint = 0.5,
                             float amp = 0.45,
                         float frequency = 2,
                                float offset = 6,
                                 float pi = 3.14,
     color fgcolor = color(0.2,0.4,0.4),
             color bgcolor =color(1,1,1),
             output color resultRGB = 0)
{
if(u >= midpoint+sin(frequency*pi*v+offset)*amp)
{           resultRGB = fgcolor;}
else
                           {resultRGB = bgcolor;
                            }
}
 
 
P O L Y G O N 
____________________________________________________________________________________________________
 

//polygon.osl
 
surface polygon( float sides = 6,
                       float innerRad = 0.4,
                       float line = 0.1,
                       color bgcolor = color(1,0,0),
                       color fgcolor = color(0,0,1),
                       output color resultRGB = 0,
                       output float resultF = 0)
{
float x = u - 0.5, y = v - 0.5;  
float R = sqrt(x * x + y * y);
float angle = atan2(y, x);
if(angle < 0.0)
             angle += 4 * M_PI;
 
float interior = (2*M_PI)/sides;
float slice = floor(angle/interior);
float rotation = (slice * interior + interior/2);
point uvPoint = point(u - 0.5, 0.5 - v, 0);
point origin = point(0, 0, 0); point z_axis = point(0, 0, 1);
point rotPoint = rotate(uvPoint, rotation, origin, z_axis);
float proximity = smoothstep(innerRad - line/2, innerRad, rotPoint[0]) *
                          (1 - smoothstep(innerRad, innerRad + line/2, rotPoint[0]));
resultRGB = mix(fgcolor, bgcolor, proximity);
}
 
C O N C L U S I O N
____________________________________________________________________________________________________
 
This project consisted of thoroughly understanding Sony's Open Shading Language
in RenderMan with the challenge of working without an interface to work between Maya and
OSL. However, this project did push me as a student to better understanding
how shading languages work and what they demand to function properly
 
 
 
 
 
RenderMan ST Coloration
Published:

RenderMan ST Coloration

These images show the results of using the RenderMan's Open Shading Language (OSL) to write a variety of traditional surface shaders. The notes a Read More

Published: